﻿<%@ Page Title="Usuários" Language="C#" MasterPageFile="~/Site.Master"
    AutoEventWireup="true" CodeBehind="CadastroUsuario.aspx.cs" Inherits="AcadPosApp.Administrativo.Cadastros.CadastroUsuario" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <style type="text/css">
        .style1
        {
            width: 312px;
        }
        .style2
        {
            width: 171px;
        }
        .style3
        {
            width: 155px;
        }
        .style6
        {
            width: 170px;
        }
        .style7
        {
            width: 61px;
        }
        .style9
        {
            width: 169px;
        }
        .style13
        {
            width: 337px;
        }
        .style14
        {
            width: 163px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Panel ID="pnlConsulta" runat="server" GroupingText="Consulta">
        <table class="form-inline">
            <tr>
                <td class="style3">
                    <asp:Label ID="Label1" runat="server" Text="Tipo Pesquisa"></asp:Label>
                    <br />
                    <asp:DropDownList ID="ddlTpPesquisa" runat="server" Width="150px" AutoPostBack="True"
                        OnSelectedIndexChanged="ddlTpPesquisa_SelectedIndexChanged">
                        <asp:ListItem Value="n">Nome</asp:ListItem>
                        <asp:ListItem Value="c">Código</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td class="style1">
                    &nbsp;<asp:RegularExpressionValidator ID="somenteLetras" runat="server" ControlToValidate="TxtPesquisa"
                        ErrorMessage="Para pesquisar por nome, digite apenas letras." ForeColor="Red"
                        ValidationExpression="([\s\'\.\^\~\´\`\\áÁ\\àÀ\\ãÃ\\âÂ\\éÉ\\èÈ\\êÊ\\íÍ\\ìÌ\\óÓ\\òÒ\\õÕ\\ôÔ\\úÚ\\ùÙ\\çÇaA-zZ]+)"
                        ValidationGroup="pesquisa" SetFocusOnError="True">*</asp:RegularExpressionValidator>
                    <asp:RegularExpressionValidator ID="revNumeros" runat="server" 
                        ControlToValidate="TxtPesquisa" 
                        ErrorMessage="Para pesquisar por código, digite apenas números." 
                        ForeColor="Red" SetFocusOnError="True" ValidationExpression="^\d*$" 
                        ValidationGroup="pesquisa" Visible="False">*</asp:RegularExpressionValidator>
                    &nbsp;&nbsp;
                    <asp:TextBox ID="TxtPesquisa" runat="server" required="" Width="300px"></asp:TextBox>
                </td>
                <td>
                    <br />
                    <asp:Button ID="btnConsultar" runat="server" Text="Consultar" OnClick="btnConsultar_Click"
                        ValidationGroup="pesquisa" Width="100px" />
                </td>
            </tr>
        </table>
        <asp:GridView ID="gvwPesquisa" runat="server" AutoGenerateColumns="False" CssClass="mGrid"
            DataKeyNames="ID_USUARIO" EmptyDataText="Dados não localizados..." GridLines="Vertical"
            OnRowCommand="gvwPesquisa_RowCommand" Width="45%" OnRowCreated="gvwPesquisa_RowCreated"
            OnRowDataBound="gvwPesquisa_RowDataBound" AllowPaging="True" 
            onpageindexchanging="gvwPesquisa_PageIndexChanging">
            <AlternatingRowStyle BackColor="#D3D3D3" />
            <Columns>
                <asp:TemplateField HeaderText="Editar" ShowHeader="False">
                    <ItemTemplate>
                        <abbr title="Editar usuário!">
                            <asp:ImageButton Width="20px" ID="ImgAlterar" runat="server" CausesValidation="false"
                                CommandName="Alterar" ImageUrl="~/Imagens/edit.png" formnovalidate="formnovalidate" Text="Alterar" />
                        </abbr>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" Width="1%" />
                    <ItemStyle HorizontalAlign="Center" Width="1%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Excluir" ShowHeader="False">
                    <ItemTemplate>
                        <abbr title="Excluir usuário!">
                            <asp:ImageButton Width="20px" ID="ImgExcluir" runat="server" CausesValidation="false"
                                OnClientClick="return ShowConfirm('Tem certeza que deseja excluir?', this.ID);"
                                CommandName="Excluir" ImageUrl="~/Imagens/delete.png" formnovalidate="formnovalidate" Text="Excluir" />
                        </abbr>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" Width="1%" />
                    <ItemStyle HorizontalAlign="Center" Width="1%" />
                </asp:TemplateField>
                <asp:BoundField DataField="NOME" HeaderText="Nome">
                    <ItemStyle HorizontalAlign="Left" Width="65%" />
                </asp:BoundField>
                <asp:BoundField DataField="EMAIL" HeaderText="E-mail">
                    <ItemStyle HorizontalAlign="Left" Width="15%" />
                </asp:BoundField>
                <asp:BoundField DataField="LOTACAO" HeaderText="Lotação">
                    <ItemStyle HorizontalAlign="Center" Width="10%" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Status">
                    <ItemTemplate>
                        <asp:Image ID="imgStatus" runat="server" Height="25px" Width="25px" />
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
                <asp:BoundField DataField="SITUACAO" HeaderText="Status">
                    <ItemStyle HorizontalAlign="Center" Width="10%" />
                </asp:BoundField>
            </Columns>
            <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
            <PagerStyle CssClass="pagination" ForeColor="Black" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#1E90FF" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#808080" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#383838" />
        </asp:GridView>
        <div class="legenda">
            <table class="form-inline">
                <tr>
                    <td class="style6" colspan="2">
                        Legenda
                    </td>
                </tr>
                <tr>
                    <td class="style9">
                        Ativo&nbsp; :
                    </td>
                    <td>
                        <asp:Image ID="Image1" runat="server" ImageUrl="~/Imagens/ativo.png" Width="25px" />
                    </td>
                </tr>
                <tr>
                    <td class="style9">
                        Inativo:
                    </td>
                    <td>
                        <asp:Image ID="Image2" runat="server" ImageUrl="~/Imagens/inativo.png" Width="25px" />
                    </td>
                </tr>
            </table>
        </div>
        <br />
        <div class="legenda">
            <asp:Button ID="btnIncluir" runat="server" formnovalidate="formnovalidate" Text="Incluir"
                OnClick="btnIncluir_Click" Width="100px" />
        </div><br />
    </asp:Panel>
    <br />
    <asp:Panel ID="pnlEdicao" runat="server" GroupingText="Cadastro de Usuários" 
        Visible="False">
        <table class="form-inline">
            <tr>
                <td class="style2" colspan="2">
                    <asp:Label ID="Label2" runat="server" Text="Nome do Usuário"></asp:Label>
                    <br />
                    <asp:TextBox ID="TxtNome" required runat="server" Width="300px" Height="30px" 
                        MaxLength="150"></asp:TextBox>
                </td>
                <td class="style13">
                    &nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label3" runat="server" Text="E-mail"></asp:Label>
                    <br />
                    <asp:TextBox ID="TxtEmail" required type="email" runat="server" Width="300px" Height="30px"
                        MaxLength="80"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style7">
                    <asp:Label ID="Label5" runat="server" Text="Lotação"></asp:Label>
                    <br />
                    <asp:DropDownList ID="ddlLotacao" runat="server" Width="145px">
                        <asp:ListItem Value="AC">AC</asp:ListItem>
                        <asp:ListItem Value="AL">AL</asp:ListItem>
                        <asp:ListItem Value="AM">AM</asp:ListItem>
                        <asp:ListItem Value="AP">AP</asp:ListItem>
                        <asp:ListItem Value="BA">BA</asp:ListItem>
                        <asp:ListItem Value="CE">CE</asp:ListItem>
                        <asp:ListItem Value="DF">DF</asp:ListItem>
                        <asp:ListItem Value="ES">ES</asp:ListItem>
                        <asp:ListItem Value="GO">GO</asp:ListItem>
                        <asp:ListItem Value="MA">MA</asp:ListItem>
                        <asp:ListItem Value="MG">MG</asp:ListItem>
                        <asp:ListItem Value="MS">MS</asp:ListItem>
                        <asp:ListItem Value="MT">MT</asp:ListItem>
                        <asp:ListItem Value="PA">PA</asp:ListItem>
                        <asp:ListItem Value="PB">PB</asp:ListItem>
                        <asp:ListItem Value="PE">PE</asp:ListItem>
                        <asp:ListItem Value="PI">PI</asp:ListItem>
                        <asp:ListItem Value="PR">PR</asp:ListItem>
                        <asp:ListItem Value="RJ">RJ</asp:ListItem>
                        <asp:ListItem Value="RN">RN</asp:ListItem>
                        <asp:ListItem Value="RO">RO</asp:ListItem>
                        <asp:ListItem Value="RR">RR</asp:ListItem>
                        <asp:ListItem Value="RS">RS</asp:ListItem>
                        <asp:ListItem Value="SC">SC</asp:ListItem>
                        <asp:ListItem Selected="True" Value="SE">SE</asp:ListItem>
                        <asp:ListItem Value="SP">SP</asp:ListItem>
                        <asp:ListItem Value="TO">TO</asp:ListItem>
                    </asp:DropDownList>
                    <br />
                </td>
                <td class="style14">
                    &nbsp;&nbsp;&nbsp;
                    <asp:Label ID="Label4" runat="server" Text="Situação"></asp:Label>
                    <br />
                    &nbsp;&nbsp;
                    <asp:DropDownList ID="ddlSituacao" runat="server" Width="145px">
                        <asp:ListItem Value="A">Ativo</asp:ListItem>
                        <asp:ListItem Value="I">Inativo</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td class="style13">
                    &nbsp;&nbsp;&nbsp;
                    <br />
                    &nbsp;&nbsp;
                </td>
            </tr>
        </table>
        <br />
        <div class="legenda">
            <asp:Button ID="btnConfirmar" runat="server" Text="Confirmar" 
                OnClick="btnConfirmar_Click" Width="100px" />
            &nbsp;
            <asp:Button ID="btnCancelar" runat="server" formnovalidate="formnovalidate" OnClick="btnCancelar_Click"
                Text="Cancelar" Width="100px" />
        </div><br />
    </asp:Panel>
    <asp:ValidationSummary ID="VSPesquisa" runat="server" ShowMessageBox="True" ShowSummary="False"
        ValidationGroup="pesquisa" />
</asp:Content>
